<%-- 
    Document   : CureServiceDetail
    Created on : 20 ?.?. 2554, 14:44:45
    Author     : SUNTIPARB
--%>
<%@ page language="java" import="java.util.*" %>
<script type="text/javascript">
<%ResourceBundle resource = ResourceBundle.getBundle("Constant_en");%>
var dataStatus =  <%= resource.getString("cureplan.status") %>;
var strSelectDefault = "<%= resource.getString("project.select.default") %>";
     // pre-submit callback
    function showRequest(formData, jqForm, options) {
//        // formData is an array; here we use $.param to convert it to a string to display it
//        // but the form plugin does this for you automatically when it submits the data
//        var queryString = $.param(formData);
//
//        // jqForm is a jQuery object encapsulating the form element.  To access the
//        // DOM element for the form do this:
//        // var formElement = jqForm[0];
//
//        alert('About to submit: \n\n' + queryString);
//
//        // here we could return false to prevent the form from being submitted;
//        // returning anything other than false will allow the form submit to continue
//        return true;
    }

    // post-submit callback
    function showResponse(responseText, statusText, xhr, $form)  {
        ContentAjaxRequest('SRV/CureServiceList', 'section #container');
    }
    (function($) {
        $.fn.getDoctor = function(){
            $.ajax({
              type: 'POST',
              url: '<%=request.getContextPath()%>/SRV/CureServiceDetail/getDoctor',
//              data: "{}",
//              contentType: "text/json; charset=utf-8",
              dataType: 'json',
              success: function(data){
                  populateSelect($('#ddlDoctorName').get(0), data, strSelectDefault, "<%=  request.getAttribute("ddlDoctorId")%>");
                  $.uniform.update("#formCureService input, #formCureService textarea, #formCureService select,#formCureService button");
//                $.each(data, function(i, j){
//                    var row = "<option value=\"" + j.value + "\">" + j.name + "</option>";
//                    $(row).appendTo("select#ddlDoctorName");
//                });
              },
              error: function(){
                  alert("Error in json");
              }
            });
        };
    })(jQuery);
    $(document).ready(function() {
        $("#ddlDoctorName").getDoctor();
        $("#formCureService input, #formCureService select,#formCureService button").uniform();
//        $("#btnReset").click(function(){
//            $("#formCureService").get(0).reset();
//            $.uniform.update("#formCureService input, #formCureService textarea, #formCureService select,#formCureService button");
//            return false});
        $("#btnBack").click(function(){
            ContentAjaxRequest('SRV/CureServiceList', 'section #container');
        });

        //Bind form submit
        var options = {
            url: '<%=request.getContextPath()%>/SRV/CureServiceDetail/formCureService_Submit',
            type: 'POST',
            dataType:  'json',
            beforeSubmit:  showRequest,  // pre-submit callback
            success:       showResponse  // post-submit callback

            // other available options:
            //url:       url         // override for form's 'action' attribute
            //type:      type        // 'get' or 'post', override for form's 'method' attribute
            //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
            //clearForm: true        // clear all form fields after successful submit
            //resetForm: true        // reset the form after successful submit

            // $.ajax options can be used here too, for example:
            //timeout:   3000
        };
        $("#formCureService").validate({
            rules: {
                txtName : "required",
                txtPrice : {
                    required:true,
                    min:0
                },
                txtCurrency : "required"
            },
            messages: {
                txtName : "Please enter Service Name",
                txtPrice : {
                    required:"Please enter Service Price",
                    min:"Please enter a value greater than or equal to 0"
                },
                txtCurrency : "Please enter Service Currency"
            },
            submitHandler: function(form) {
                $(form).ajaxSubmit(options);
            }
        });

    });


</script>
<%-- End Form Function --%>
<!-- insert content here -->
<h3>Cure Service Detail</h3>
<div class="grid_8">
    <div class="box1">
        <div class="indent-box1">
            <div class="wrapper">
                <form id="formCureService" class="form" method="GET">
                <!-- Query String -->
                    <input type="hidden" id="cureServiceId" name="cureServiceId" value="<%=  request.getAttribute("cureServiceId")%>" />
                <!-- End Query String -->
                    <table>
                        <tr>
                            <td><em>Service Name</em></td>
                        </tr>
                        <tr>
                            <td>
                                <div class="p1" id="txtName_wrapper">
                                    <input type="text" name="txtName" id="txtName" class="width-100" value="<%=  request.getAttribute("txtName")%>" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td><em>Service Price</em></td>
                        </tr>
                        <tr>
                            <td>
                                <div class="p1" id="txtPrice_wrapper">
                                    <input type="text" name="txtPrice" id="txtPrice" class="width-100" value="<%=  request.getAttribute("txtPrice")%>" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td><em>Service Currency</em></td>
                        </tr>
                        <tr>
                            <td>
                                <div class="p1" id="txtCurrency_wrapper">
                                    <input type="text" name="txtCurrency" id="txtCurrency" class="width-100" value="<%=  request.getAttribute("txtCurrency")%>" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td><em>Doctor Name</em></td>
                        </tr>
                        <tr>
                            <td>
                                <div class="p1" id="ddlDoctorName_wrapper">
                                    <select name="ddlDoctorName" id="ddlDoctorName">
<!--                                        <option value="<%=  request.getAttribute("ddlDoctorId")%>" selected="true"><%=  request.getAttribute("ddlDoctorName")%></option>-->
                                    </select>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="control">
                                <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
                                <input type="button" name="btnBack" id="btnBack" value="Back" />
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
